﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;

namespace BugZillaCrawler.UI
{
    public static class DomUtility
    {
        public static bool MatchAttributes(this XmlElement self, params string[] tokens)
        {
            bool result = true;
            for (int i = 0; i < tokens.Length; i += 2)
            {
                if (self.Attributes[tokens[i]] != null && string.Compare(self.Attributes[tokens[i]].Value, tokens[i + 1], true) == 0)
                {
                    // attribute content matched, check next attribute
                    continue;
                }
                else
                {
                    // attribute does not match
                    result = false;
                    break;
                }
            }

            return result;
        }
    }
}
